package com.ruoyi.merchant.mapper;

import com.ruoyi.merchant.domain.MerchantApplication2;
import org.apache.ibatis.annotations.Param;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 商家入驻申请Mapper接口
 */
public interface MerchantApplication2Mapper {
    /**
     * 插入申请记录
     */
    int insertApplication(MerchantApplication2 application);

    /**
     * 根据商家ID查询最新的申请记录
     */
    MerchantApplication2 selectLatestByMerchantId(@Param("merchantId") Long merchantId);

    /**
     * 根据申请ID查询
     */
    MerchantApplication2 selectApplicationById(@Param("applicationId") Long applicationId);

    /**
     * 根据邮箱查询（检查重复）
     */
    MerchantApplication2 selectApplicationByEmail(@Param("email") String email);

    /**
     * 更新申请状态
     */
    int updateApplicationStatus(@Param("applicationId") Long applicationId,
                                @Param("status") Integer status);

    /**
     * 更新申请信息
     */
    int updateApplication(MerchantApplication2 application);

    /**
     * 查询申请列表（支持条件查询）
     */
    List<MerchantApplication2> selectApplicationList(MerchantApplication2 application);
    /**
     * 查询商家的所有申请记录
     */
    List<MerchantApplication2> selectApplicationsByMerchantId(@Param("merchantId") Long merchantId);

    int updateByMerchantId(MerchantApplication2 updateApplication);

    MerchantApplication2 selectByMerchantId(Long merchantId);

    MerchantApplication2 selectApplicationByLicense(@NotBlank(message = "营业执照图片不能为空") String businessLicense);

    //更新申请状态（用于审核）
    int updateApplicationStatus2(MerchantApplication2 application);

    /**
     * 查询审核列表
     */
    List<MerchantApplication2> selectAuditList(MerchantApplication2 application);

    /**
     * 根据审核状态统计数量
     */
    int countByStatus(@Param("applicationStatus") Integer applicationStatus);
}
